<template>
  <!--头部-->
  <div class="public-head">
    <div class="public-head-nav">
      <div class="public-head-left">
        <h1 class="public-head-logo"><a href="javascript:;">
          <img src="@/assets/image/logo.png" alt="">
        </a></h1>
        <ul class="public-head-list">
          <li><a href="/">主页</a></li>
          <li class="public-head-hover">
            <a href="javascript:void(0);">我要投资</a>
            <!--二级导航-->
            <div class="two-title">
              <a href="/product/list?type=1">优选类产品</a>
              <a href="/product/list?type=2">散标类产品</a>
            </div>
          </li>
          <li><a href="javascript:;" >借款人信息</a></li>
          <li><a href="javascript:;" >信息披露</a></li>
          <li><a href="javascript:;" >安全计划</a></li>
        </ul>
      </div>
      <div class="public-head-right" v-if="login">
        <a href="/user/realname">实名认证</a>
        <a href="/user/center">用户中心</a>
        <a href="javascript:void (0)" @click="exit">退出</a>
      </div>
      <div class="public-head-right" v-else>
        <a href="/user/login">登录</a>
        <a href="/user/register">注册</a>
      </div>
    </div>
  </div>
  <!--end-->

</template>

<script>
import {doGet} from "@/utils/request";

export default {
  name: "AppHeader",
  data(){
    return {
      login:false
    }
  },
  mounted() {
    //判断登录.
    let ylbToken=window.sessionStorage.getItem("ylb");
    if (ylbToken){
      this.login=true;
    }
  },
  methods:{
    exit(){
      doGet("/user/logout").then(resp=>{
        if (resp.code === 999){
          window.sessionStorage.removeItem("ylb");
          window.location.href="/";
        }
      })
    },

  }
}
</script>

<style scoped>

</style>